//
//  YDLinkedInAccount.m
//  IngCard
//
//  Created by kf on 2017/9/6.
//  Copyright © 2017年 IngDan. All rights reserved.
//

#import "YDLinkedInAccount.h"


@implementation YDLinkedInAccountPosition

@end


@implementation YDLinkedInAccount

+(YDLinkedInAccount *) serializeWith:(NSDictionary *) dic
{
    if(!dic) return nil;
    
    YDLinkedInAccount *result = [[YDLinkedInAccount alloc] init];
    
    result.name = NSStringMake(dic[@"name"]);
    result.location = NSStringMake(dic[@"location"]);
    result.email = NSStringMake(dic[@"email"]);
    result.profileUrl = NSStringMake(dic[@"public_profile_url"]);
    result.headPic = NSStringMake(dic[@"head_pic"]);
    result.companyName = NSStringMake(dic[@"company_name"]);
    result.occupation = NSStringMake(dic[@"occupation"]);
    
    NSArray *positionArray = NSArrayMake(dic[@"position"]);
    NSMutableArray *positions = [NSMutableArray array];
    
    for(int i = 0; i < positionArray.count; i++)
    {
        NSDictionary *positionDic = NSDictionaryMake(positionArray[i]);
        
        YDLinkedInAccountPosition *position = [[YDLinkedInAccountPosition alloc] init];
        position.company = NSStringMake(positionDic[@"company"]);
        position.title = NSStringMake(positionDic[@"title"]);
        position.startYear = NSStringMake(positionDic[@"startYear"]);
        position.startMonth = NSStringMake(positionDic[@"startMonth"]);
     
        [positions safeAddObject:position];
    }
    
    result.positions = positions;//[NSArray arrayWithArray:positions];
    return result;
}
@end
